<template>
	<view class="index">
		<view class="banner">
			<swiper 
			:indicator-dots="true" 
			:autoplay="true" 
			:interval="3000" 
			:duration="1000">
				<swiper-item v-for="item in list">
					<view class="swiper-item">
						<image class="img" :src="item.bannerImg" mode="widthFix"></image>
					</view>
				</swiper-item>
			</swiper>
		</view>
		<view class="category">
			<view class="user">
				<view class="left">
					<text>Hey,来跟幸运打个招呼</text>
				</view>
				<view class="right">
					<text>小蓝鹿</text>
				</view>
			</view>
			<view class="top">
				<view class="box" @click="goCategory">
					<image src="../../static/assets/qu.png" mode="widthFix" />
					<view class="title">
						<text>到店取</text>
					</view>
					<view class="text">
						<text>提前点单免排队</text>
					</view>
				</view>
				<view class="box">
					<image src="../../static/assets/shop.png" mode="widthFix"></image>
					<view class="title">
						<text>幸运送</text>
					</view>
					<view class="text">
						<text>外卖及时送达</text>
					</view>
				</view>
				<view class="box">
					<image src="../../static/assets/waimai.png" mode="widthFix"></image>
					<view class="title">
						<text>电商取</text>
					</view>
					<view class="text">
						<text>囤咖啡送周边</text>
					</view>
				</view>
			</view>
			<view class="bottom">
				<view class="box">
					<image src="../../static/assets/fireworks.png" mode="widthFix" alt="" />
					<view class="title">
						<text>11.11狂欢</text>
					</view>
					<view class="text">
						<text>抽iphone16</text>
					</view>
				</view>
				<view class="box">
					<image src="../../static/assets/gift.png" mode="widthFix" alt="" />
					<view class="title">
						<text>礼品卡</text>
					</view>
					<view class="text">
						<text>送TA咖啡</text>
					</view>
				</view>
				<view class="box">
					<image src="../../static/assets/drink.png" mode="widthFix" alt="" />
					<view class="title">
						<text>多人团餐</text>
					</view>
					<view class="text">
						<text>一键开票</text>
					</view>
				</view>
				<view class="box">
					<image src="../../static/assets/peoples.png" mode="widthFix" alt="" />
					<view class="title">
						<text>拼单满减</text>
					</view>
					<view class="text">
						<text>一起点更划算</text>
					</view>
				</view>
			</view>
		</view>
	</view>
</template>

<script>
	import { bannerFn } from '../../api/index.js'
	export default {
		data() {
			return {
				list: []
			}
		},
		onLoad(options) {
			this.BannerFn();
		},
		methods: {
			async BannerFn(){
				await bannerFn({appkey:"U2FsdGVkX19WSQ59Cg+Fj9jNZPxRC5y0xB1iV06BeNA="})
				.then(
					content=>{
						// console.log(content);
						let {code,result} = content;
						if(code == 300){
							this.list = result;
						}
					}
				)
			},
			goCategory(){
				uni.switchTab({
					url:'/pages/menu/menu'
				})
			}
		}
	}
</script>

<style lang="scss">
	.index{
		// position: relative;
		.banner{
			swiper{
				height: 560rpx;
			}
			.swiper-item{
				width: 100%;
				height: 100%;
				.img{
					width: 100%;
					height: 100%;
				}
			}
		}
		.category{
			width: 90%;
			height: 520rpx;
			border: 1px solid black;
			margin-left: 5%;
			border-radius: 20rpx;
			// position: absolute;
			// top: 480rpx;
			margin-top: 50rpx;
			.user{
				width: 100%;
				height: 80rpx;
				display: flex;
				justify-content: space-between;
				background-color: #000;
				line-height: 80rpx;
				border-top-right-radius: 20rpx;
				border-top-left-radius: 20rpx;
				.left{
					padding-left: 20rpx;
					font-size: 12px;
					color: #f0a54c;
				}
				.right{
					height: 50rpx;
					padding-right: 20rpx;
					color: #f0a54c;
				}
			}
			.top{
				display: flex;
				justify-content: space-around;
				.box{
					text-align: center;
					padding: 20rpx 10rpx;
					image{
						width: 80%;
					}
					.title{
						font-weight: 600;
						margin-bottom: 5rpx;
					}
					.text{
						font-size: 24rpx;
						color: #ccc;
					}
				}
			}
			.bottom{
				display: flex;
				margin-top: 5rpx;
				// border: 1px solid black;
				justify-content: space-around;
				.box{
					text-align: center;
					image{
						width: 50rpx;
					}
					.title{
						margin-bottom: 5rpx;
						font-size: 28rpx;
						font-weight: 500;
					}
					.text{
						font-size: 24rpx;
						color: #ccc;
					}
				}
			}
		}
	}
</style>
